package com.foreveross.fetl.core.domain.single;

import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

import com.dayatang.domain.InstanceFactory;
import com.foreveross.fetl.common.vo.model.SinglePlaneInfo;
import com.foreveross.fetl.core.domain.single.repository.ISinglePlaneInfoRepository;

public class SinglePlaneInfoEntity extends SinglePlaneInfo {
	
	

	private Long id;
	
	
	
	/**
	 * PlaneInfoEntity ID
	 */
	private Long jsonId;
	
	private PlaneInfoJsonEntity planeInfoJsonEntity;

	
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getJsonId() {
		return jsonId;
	}

	public void setJsonId(Long jsonId) {
		this.jsonId = jsonId;
	}
	
	

	public PlaneInfoJsonEntity getPlaneInfoJsonEntity() {
		return planeInfoJsonEntity;
	}

	public void setPlaneInfoJsonEntity(PlaneInfoJsonEntity planeInfoJsonEntity) {
		this.planeInfoJsonEntity = planeInfoJsonEntity;
	}
	

	public ISinglePlaneInfoRepository getISinglePlaneInfoRepository(){
		return InstanceFactory.getInstance(ISinglePlaneInfoRepository.class);
	}
	/**
	 * 保存航班
	 * @param entity
	 * @throws SQLException
	 */
	public void create(SinglePlaneInfoEntity entity) throws SQLException{
		 getISinglePlaneInfoRepository().create(entity);
	}
	
	public void create(Collection<SinglePlaneInfoEntity> set)throws SQLException{
		getISinglePlaneInfoRepository().create(set);
	}
	/**
	 * 删除航班实时最低价
	 * @param entity
	 * @throws SQLException
	 */
	public void delete(SinglePlaneInfoEntity entity) throws SQLException {
		getISinglePlaneInfoRepository().delete(entity);
	}
	
	/**
	 * 根据条件删除 请确保每个参数都不为空
	 * @param hbaseKey
	 * @param fromCity
	 * @param toCity
	 * @param flightDate
	 * @param flightNo
	 */
	public void delete(String hbaseKey,String fromCity,String toCity,String flightDate,String flightNo)throws SQLException{
		getISinglePlaneInfoRepository().delete(hbaseKey, fromCity, toCity, flightDate, flightNo);
	}
	public void delete(Collection<SinglePlaneInfoEntity> oldList) throws SQLException{
		getISinglePlaneInfoRepository().delete(oldList);
	}
	
	/**
	 * 查询航班实时最低价 （只获取ID）
	 * @param hbaseKey
	 * @param fromCity
	 * @param toCity
	 * @param flightBatchDate
	 * @param flightNo
	 * @return
	 * @throws SQLException
	 */
	public List<SinglePlaneInfoEntity> findByCondition(String hbaseKey,
			String fromCity, String toCity, String flightBatchDate,
			String flightNo) throws SQLException {
		return getISinglePlaneInfoRepository().findByCondition(hbaseKey,
				fromCity, toCity, flightBatchDate, flightNo);
	}
	/**
	 * 查询航班实时最低价 （只获取planeInfo的主属性）
	 * @param hbaseKey
	 * @param carrierKey
	 * @param fromCity
	 * @param toCity
	 * @param flightBatchDate
	 * @param flightNo
	 * @return
	 */
	public List<SinglePlaneInfoEntity> findPlaneInfoProperty(String hbaseKey,String carrierKey,
			String fromCity, String toCity, String flightBatchDate,
			String flightNo,String grabDate) {
		return getISinglePlaneInfoRepository().findPlaneInfoProperty(hbaseKey,carrierKey,
				fromCity, toCity, flightBatchDate, flightNo,grabDate);
	}
	/**
	 * 查询航班实时最低价
	 * @param hbaseKey
	 * @param fromCity
	 * @param toCity
	 * @param flightBatchDate
	 * @param flightNo
	 * @return
	 */
	public List<SinglePlaneInfoEntity> findPlanInfoAndFamily(String hbaseKey,
			String fromCity, String toCity, String flightBatchDate,
			String flightNo) {
		return getISinglePlaneInfoRepository().findPlanInfoAndFamily(hbaseKey,
				fromCity, toCity, flightBatchDate, flightNo);
	}
	
	/**
	 * 查询一小时内的数据
	 * @param hbaseKey
	 * @param fromCity
	 * @param toCity
	 * @param grabDate String yyyyMMddHH 2014032721
	 * @return
	 */
	public List<SinglePlaneInfoEntity> findByGrabDate(String hbaseKey,
			String fromCity, String toCity,String grabDate){
		return getISinglePlaneInfoRepository().findByGrabDate(hbaseKey, fromCity, toCity, grabDate);
	}

	
	
	/**
	 * 删除当天航线最低价
	 * @param entity
	 * @throws SQLException
	 */
	public void deleteFormPlaneDay(SinglePlaneInfoEntity entity) throws SQLException{
		 getISinglePlaneInfoRepository().deleteFormPlaneDay(entity);
	}
	
	/**
	 * 保存当天航线最新最低价
	 * @param entity
	 * @throws SQLException
	 */
	public void creatToPlaneDay(SinglePlaneInfoEntity entity) throws SQLException{
		 getISinglePlaneInfoRepository().creatToPlaneDay(entity);
	}
	
	/**
	 * 查询当天航线最新最低价
	 * @param hbaseKey
	 * @param fromCity
	 * @param toCity
	 * @param flightBatchDate
	 * @return
	 * @throws SQLException
	 */
	public List<SinglePlaneInfoEntity> findFromPlaneDay(String hbaseKey,
			String fromCity, String toCity, String flightBatchDate) throws SQLException{
		return getISinglePlaneInfoRepository().findFromPlaneDay(hbaseKey, fromCity, toCity, flightBatchDate);
	}

	

	
}
